#include "ItemSelectionDialog.h"
#include <QLineEdit>
#include <QVBoxLayout>

ItemSelectionDialog::ItemSelectionDialog(QWidget* parent)
	: QDialog(parent)
	  , edit_(0)
{
	initializeMap();
	initialize();
}

ItemSelectionDialog::~ItemSelectionDialog()
{

}

void ItemSelectionDialog::initialize()
{
	QVBoxLayout* layout = new QVBoxLayout(this);
	edit_ = new QLineEdit;
	connect(edit_, SIGNAL(textChanged(const QString&)), 
		this, SLOT(onLineTextChanged(const QString&)));
	layout->addWidget(edit_);
}

void ItemSelectionDialog::onLineTextChanged(const QString& text)
{

}

void ItemSelectionDialog::setPressedKey(int key)
{
	char c = keyMap_[key];
	QString str;
	str.push_back(c);
	edit_->setText(str);
}

void ItemSelectionDialog::initializeMap()
{
	keyMap_ = {{Qt::Key_0, '0'}, {Qt::Key_1, '1'},
		{Qt::Key_2, '2'}, {Qt::Key_3, '3'},
		{Qt::Key_4, '4'}, {Qt::Key_5, '5'},
		{Qt::Key_6, '6'}, {Qt::Key_7, '7'},
		{Qt::Key_8, '8'}, {Qt::Key_9, '9'},
	       	{Qt::Key_A, 'A'}, {Qt::Key_B, 'B'},
		{Qt::Key_C, 'C'}, {Qt::Key_D, 'D'},
		{Qt::Key_E, 'E'}, {Qt::Key_F, 'F'},
		{Qt::Key_G, 'G'}, {Qt::Key_H, 'H'},
		{Qt::Key_I, 'I'}, {Qt::Key_J, 'J'},
		{Qt::Key_K, 'K'}, {Qt::Key_L, 'K'},
		{Qt::Key_M, 'M'}, {Qt::Key_N, 'N'},
		{Qt::Key_O, 'O'}, {Qt::Key_P, 'P'},
		{Qt::Key_Q, 'Q'}, {Qt::Key_R, 'R'},
		{Qt::Key_S, 'S'}, {Qt::Key_T, 'T'},
		{Qt::Key_U, 'U'}, {Qt::Key_V, 'V'},
		{Qt::Key_W, 'W'}, {Qt::Key_X, 'X'},
		{Qt::Key_Y, 'Y'}, {Qt::Key_Z, 'Z'}};

//keyMap_.insert
}
